package com.csot.queue;

import javax.annotation.PostConstruct;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

@Service
public class QueueHolder {

	private static final Logger log = LoggerFactory.getLogger(QueueHolder.class);

	private static final QueueKit qk = new QueueKit();

	@PostConstruct
	public void init() {
		new Thread(() -> {
			try {
				qk.start();
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				log.error("队列启动失败", e);
			}
		}).start();

	}

	public static void offer(Runnable r) {
		qk.produce(r);
	}

}
